<?php
header("Access-Control-Allow-Origin:*");
/*
3.教师开始新的点名
接口方式:http post
接口:addPoint.php
返回数据:"ok" 告诉教师创建成功
传入数据:{"pointTime":"1234566723"}
测试地址:http://192.168.16.115/openapi/om_html5/addPoint.php?pointTime=1234566723
*/
//error_reporting(E_ERROR | E_WARNING | E_PARSE);
@error_reporting(0);
@set_time_limit(0);
@set_magic_quotes_runtime(0);
@ini_set('memory_limit','512M');
//ini_set("display_errors","On");
//error_reporting(E_ALL);
$whiteboard_config_array = array();
$data['pointTime'] = isset($_REQUEST['pointTime']) ? $_REQUEST['pointTime']:'';
$data['roomId'] = isset($_REQUEST['roomId']) ? $_REQUEST['roomId']:'';
$sn_group_id = isset($_REQUEST['sn_group_id']) ? $_REQUEST['sn_group_id']:'';
if($data['pointTime'] && $data['roomId']){
    //DEBUG 解析白板配置文件
    $isp = isset($_REQUEST['isp']) && !empty($_REQUEST['isp']) ? $_REQUEST['isp']:'';//运营商编号 1 电信 2 移动 3 联通
    if(empty($isp)){
        $isp = 1;
    }
    $whiteboard_config_array = parse_ini_file("../../config/room/config_whiteboard_".$isp.".ini", false);
    require '../../source/class/memory/memory_driver_redis_multi.php';
    $config_redis = array();
    $config_redis['master'] = array(
        array('host'=>$whiteboard_config_array['MEMORY_REDIS_MASTER_SERVER'],
            'port'=>$whiteboard_config_array['MEMORY_REDIS_MASTER_PORT'],
            'auth'=>$whiteboard_config_array['MEMORY_REDIS_MASTER_AUTH'],
            'db'=>$whiteboard_config_array['MEMORY_REDIS_MASTER_DB'],
            'pconnect'=>$whiteboard_config_array['MEMORY_REDIS_MASTER_PCONNECT'],
            'timeout'=>$whiteboard_config_array['MEMORY_REDIS_MASTER_TIMEOUT']
        )
    );
    $config_redis['slave'] = array(
        array('host'=>$whiteboard_config_array['MEMORY_REDIS_SLAVE_SERVER'],
            'port'=>$whiteboard_config_array['MEMORY_REDIS_MASTER_PORT'],
            'auth'=>$whiteboard_config_array['MEMORY_REDIS_MASTER_AUTH'],
            'db'=>$whiteboard_config_array['MEMORY_REDIS_MASTER_DB'],
            'pconnect'=>$whiteboard_config_array['MEMORY_REDIS_MASTER_PCONNECT'],
            'timeout'=>$whiteboard_config_array['MEMORY_REDIS_MASTER_TIMEOUT']
        )
    );
    //DEBUG 初始化redis
    $redis = RedisClient::getInstance($config_redis);
    @file_put_contents('./logs/point/'.$data['pointTime'].'.log','');
    //DEBUG 初始化redis
    $redis = RedisClient::getInstance($config_redis);
    $point_num = $redis->set('point_num_'.$data['pointTime'],1);
    $redis->close();
    echo 'ok';
}
?>